#include "PlayerMgr.h"
#include "dbProto/dbTableDef.h"
#include "db_driver/db_driver.h"
#include "ZoneSvr.h"

using namespace su;
using namespace std;
using namespace proto;

PlayerBase::PlayerBase(Player& player)
	:PlayerComponent(player)
{
	Reg<EvNewPlayer>(&PlayerBase::OnNewPlayer); //reg OnNewPlayer
	Reg<EvAfterInitFromDb>(&PlayerBase::OnAfterInitFromDb);
}

void PlayerBase::OnNewPlayer()
{
	SDEBUG("PlayerBase::OnNewPlayer");
}

void PlayerBase::OnAfterInitFromDb()
{
	m_savetm.Start(60 * 5, &PlayerBase::SaveDb, this, true);
}

void PlayerBase::SaveDb()
{
	Dbproxy::Ins().Update(m_owner.m_db);
	ZoneSvr::Ins().m_ConToCenter.Call("UpdateScene", m_owner.m_PlayerScene.m_dbScene.cfgId, m_owner.m_PlayerScene.m_dbScene.id);
}